package com.neuedu.controller.user;

import com.neuedu.factory.ClassFactory;
import com.neuedu.service.AddDeptService;
import com.neuedu.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "AddUserServlet", urlPatterns = "/his/adduser")
public class AddUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String loginname = request.getParameter("loginname");
        String name = request.getParameter("name");
        String pass = request.getParameter("pass");
        String deptment = request.getParameter("deptment");
        String usercategoryname = request.getParameter("usercategoryname");
        String doctorposition = request.getParameter("doctorposition");
        String registeredlevel = request.getParameter("registeredlevel");
        String isscheduling = request.getParameter("isscheduling");
        Object[] objs = {loginname, name, pass, deptment, usercategoryname, doctorposition, registeredlevel, isscheduling};
        UserService us = (UserService) ClassFactory.createObj("UserService");
        int flag = us.addUser(objs);
        String rs = "";
        if (flag >= 1) {
            rs = "true";
        } else {
            rs = "false";
        }
        response.getWriter().append(rs);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
